package view;

import java.awt.image.*;
import java.awt.Point;
import java.io.File;
import java.awt.Graphics;
import java.io.IOException;
import javax.imageio.ImageIO;

public class ObjectRepresentation
{
	private BufferedImage img;
	private final int width;
	private final int height;
	private final int unitheight;
	
	public ObjectRepresentation(String imgID)
	{
		try
		{
			img = ImageIO.read(new File("images/"+imgID+".png"));
		}
		catch (IOException e)
		{
			System.out.println("ERROR loading image "+imgID);
		}
		width = img.getWidth();
		height = img.getHeight();
		unitheight = height/8;
	}
	
	//doesn't handle rotations yet since that hasn't been put in yet
	public void draw(Graphics g, Point p)
	{
		int x = ((Double) p.getX()).intValue();
		int y = ((Double) p.getY()).intValue();
		g.drawImage(img, x, y, x+width, y+height, 0, 0, 40, 40, null);
	}
	
	public BufferedImage getSimpleImage()
	{
		return img.getSubimage(0,0,width,unitheight); //this will be fixed later, this is just for testing
	}
}	
	